package com.wn.date20190814;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * 3，从键盘输入若干用户的姓名，按照姓氏统计人数
 * @author song
 *
 */
public class LastNameCount
{

	public static void main(String[] args)
	{
		Scanner scanner=new Scanner(System.in);
		Map<String, Integer> map=new HashMap<String, Integer>();
		while (true)
		{
			System.out.println("请输入姓名，输入0退出");
			String name=scanner.next();
			if(name.equals("0"))
			{
				break;
			}
			String firstname=name.substring(0, 1);
			map.put(firstname, map.get(firstname)==null?1:map.get(firstname)+1);
			
		}
		scanner.close();
		System.out.println(map);
	}

}
